﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace BeniBastanYaratProject.Uye
{
    public partial class Siparislerim : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Visible = false;
            Label1.Text = null;
            DBBaglantiDataContext dbaglanti = new DBBaglantiDataContext();
            string aktifUserKey = Membership.GetUser().ProviderUserKey.ToString();
            lblUyeAdi.Text = Membership.GetUser().UserName;
            lblUyeNo.Text = aktifUserKey.Substring(0, 6) + "########";
            
            
            

            var sorgu6 = (from detay in dbaglanti.SiparisDetaylaris
                         join siparis in dbaglanti.Siparislers on detay.SiparisID equals siparis.SiparisID
                         join urun in dbaglanti.Urunlers on detay.UrunID equals urun.UrunID where siparis.UserID.ToString() == aktifUserKey
                         select new { detay.SiparisID, urun.UrunAdi, detay.Adet, detay.Fiyat, siparis.SiparisTarihi }).ToList();
           
            var siparisvarmi = (from x in dbaglanti.Siparislers where aktifUserKey == x.UserID.ToString() select x).ToString();
            if (siparisvarmi == null)
            {
                Label1.Visible = true;
                Label1.Font.Bold = true;
                Label1.Text =  "Daha Önceden Vermiş Olduğunuz Bir Siparişiniz Bulunmamaktadır.";

            }
            else
            {
                DataList1.DataSource = sorgu6;
                DataList1.DataBind();

            }


        }
    }
}